﻿using System;
using System.Collections.Generic;

using Moe.ECamel.Common.Contracts;
using Moe.ECamel.Common.Entities;
using Moe.ECamel.Server.BL;

namespace Moe.ECamel.Server.Services
{
	public class MailMessageService : ECamelService, IMailMessageService
	{
		public MailMessageService()
			: base()
		{
		}

		public MailMessageService(ECamelService caller)
			: base(caller)
		{
		}

		public void SendMessage(MailMessage message)
		{
			using (var bl = new MailMessageBL(GetReadWriteDataContext()))
			{
				bl.CreateMessage(message);
			}

			SubmitChanges();
		}

		public IList<MailMessage> GetUserMailMessages(int userId)
		{
			using (var bl = new MailMessageBL(GetReadOnlyDataContext()))
			{
				return bl.GetMailMessagesByUserId(userId);
			}
		}
	}
}
